/**
 * @Description: TODO(用一句话描述该文件做什么)
 */
package org.shanktech.tshare.binlogsync.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;

/**
 * @author sztan nanjing_xiaotan@163.com
 * @date 2017年6月26日 上午12:14:12
 * @version V1.0
 */
@Configurable
@EnableSwagger
public class SwaggerConfig {
  private SpringSwaggerConfig springSwaggerConfig;

  /**
   * Required to autowire SpringSwaggerConfig
   */
  @Autowired
  public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
    this.springSwaggerConfig = springSwaggerConfig;
  }

  /**
   * Every SwaggerSpringMvcPlugin bean is picked up by the swagger-mvc framework
   * - allowing for multiple swagger groups i.e. same code base multiple swagger
   * resource listings.
   */
  @Bean
  public SwaggerSpringMvcPlugin customImplementation() {
    return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
        .apiInfo(apiInfo()).includePatterns(".*?");
  }

  private ApiInfo apiInfo() {
    ApiInfo apiInfo =
        new ApiInfo("My Apps API Title", "My Apps API Description",
            "My Apps API terms of service", "My Apps API Contact Email",
            "My Apps API Licence Type", "My Apps API License URL");
    return apiInfo;
  }
}
